<?php
namespace Tbf\Bundle\DatabaseBundle\ListQuery\ConditionalExpress;
use Doctrine\ORM\QueryBuilder;

/**
 *
 * 生成如下的表达式,where a like %王% and b like %赵%
 *
 */
class AndLikeCombineConditionalExpress extends AbstractConditionalExpress
{
    protected $_express_list = array();
    protected $place_holder_num = 0;
    public function __construct($express_list)
    {
        $this->_express_list = $express_list;
    }
    public function addExpress($express)
    {
        $this->_express_list[] = $express;
    }
    public function getExpressList()
    {
        return $this->_express_list;
    }
    public function filterOrmQueryBuilder(QueryBuilder $qb)
    {
        foreach ($this->getExpressList() as $express_array) {
            $field = $this->handleFieldName($qb,$express_array['field']);
            $qb->andWhere($qb->expr()->like($field,
                $this->placeHolderValue($qb,'%'.$express_array['value'].'%')));
        }
    }

}
